package com.example.demo.mapStruct.controller;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import javax.swing.table.TableRowSorter;

/**
 * map-struct demo
 */
// 1.@Mapper
// 2.通过spring注入
@Mapper(componentModel = "spring")
public interface DemoMapper {
    // 1.通过调用Mappers.getMapper(YourClass.class) 来获取 MapStruct 中映射器的实例
    //DemoMapper instance = Mappers.getMapper(DemoMapper.class);


    DemoPojo.vo tVo(DemoPojo.dto dto);

    DemoPojo.vo1 tVo1(DemoPojo.dto dto);

    @Mappings({
            @Mapping(target = "sex", constant = "111")
    })
    DemoPojo.vo1 tVo11(DemoPojo.dto dto);

    @Mappings({
            @Mapping(target = "agentName", source = "dto.name", defaultValue = "男")
    })
    DemoPojo.vo2 tVo2(DemoPojo.dto dto);



    @Mappings({
            @Mapping(target = "agentName", source = "vo.name", defaultValue = "男"),
            @Mapping(target = "id", source = "vo.id"),
            @Mapping(target = "age", source = "vo5.age")
    })
    DemoPojo.vo6 tVo6(DemoPojo.vo vo, DemoPojo.vo5 vo5);
}
